/**
 ************************************************************************************************************
 * 
 ************************************************************************************************************
 * @file RBD3D9FXTechnique.h
 ************************************************************************************************************/

#ifndef __RBD3D9FXTECHNIQUE__H__
#define __RBD3D9FXTECHNIQUE__H__

#ifdef  HEADER_ONCE
#pragma HEADER_ONCE
#endif

#ifdef  HEADER_MSG
#pragma HEADER_MSG(RBD3D9FXTechnique.h)
#endif

/************************************************************************************************************
 * Includes
 ************************************************************************************************************/
#include <RBMain/RBTechniqueShader.h>

/************************************************************************************************************
 * Forward declarations
 ************************************************************************************************************/
struct ID3DXEffect;

/************************************************************************************************************
 * Class
 ************************************************************************************************************/

class RBD3D9FXTechnique : public RBTechniqueShader
{
    RBDeclareRTTI(RBD3D9FXTechnique, RBTechniqueShader);
    friend class RBD3D9FXLibrary;
public:
				    RBD3D9FXTechnique   (RBRenderer* pRenderer, ID3DXEffect* pEffect, D3DXHANDLE hTechnique);
	virtual	       ~RBD3D9FXTechnique   ();
	
    virtual bool    Load                (bool bReload = false);

    virtual bool    BeginPasses         (const Renderable&);
    virtual void    EndPasses           (const Renderable&);
    virtual void    BeginPass           (const Renderable&, uint32 uiPass);
    virtual void    EndPass             (const Renderable&, uint32 uiPass);
    virtual void    SetupShaders        (const Renderable&, uint32 uiPass);

    D3DXHANDLE      GetTechnique        ();
    ID3DXEffect*    GetEffect           ();

    virtual void    SetMatrix           (const float4x4* mat, const RBTechniqueParameter* pParam, uint32 uiCount = 1);
    virtual void    SetVector           (const float4* vec, const RBTechniqueParameter* pParam, uint32 uiCount = 1);
    virtual void    SetTexture          (const RBTexture* pTexture, const RBTechniqueParameter* pParam);
    virtual void    SetValue            (const void* pData, uint32 uiSize, const RBTechniqueParameter* pParam);

private:
    
private:
    D3DXHANDLE      m_hTechnique;
    ID3DXEffect*    m_pEffect;
};

RBDeclareSmartPointer(RBD3D9FXTechnique);

/************************************************************************************************************/

/***********************************************************************************************************
 * 
 ***********************************************************************************************************/
inline D3DXHANDLE RBD3D9FXTechnique::GetTechnique()
{
    return m_hTechnique;
}

/***********************************************************************************************************
 * 
 ***********************************************************************************************************/
inline ID3DXEffect* RBD3D9FXTechnique::GetEffect()
{
    return m_pEffect;
}

#endif // __RBD3D9FXTECHNIQUE__H__
